<div class="easyui-panel" id='pageSummary' title="摘要" style="padding:10px;">
    查看交易记录明细...
</div>
<script>
    $.post('?m=Api/FinanceTransactionLog&action=read_summary',function(data){
        var $strongs=$('#pageSummary').find('strong');
        $strongs.eq(0).text(data.all);
        $strongs.eq(1).text(data.confirmed);
        $strongs.eq(2).text(data.unconfirmed);
    },'json');
    </script>
<table id="dg" title="交易记录管理" class="easyui-datagrid" style="width:700px;height:365px" url="?m=Api/FinanceTransactionLog"  toolbar="#toolbar" pagination="true"  rownumbers="true" fitColumns="true" singleSelect="true">
    <thead>
        <tr>
            <th field="SerialNo" width="50">流水号</th>
            <th field="UserName" width="50">用户名</th>
            <th field="TransactionType" width="50">交易类型</th>
            <th field="Amount" width="50">交易金额</th>
            <th field="Blance" width="50">可用余额</th>
            <th field="FrozenBlance" width="60">不可用余额</th>
            <th field="UserRemark" width="50">用户备注</th>
            <th field="CreatedTime" width="50">申请时间</th>
            <th field="ModifiedTime" width="50">受理时间</th>
            <th field="AdminRemark" width="50">审核备注</th>
            <th field="State" width="50" data-options="formatter:function(v,r,i){return getStateStr(r.ID,v);},styler:function(v,r,i){return setRowStyler(v);}">状态</th>
        </tr>
    </thead>
</table>
<div id="toolbar">
    <div>
            会员名称： <input class="easyui-datebox" style="width:80px">
            交易日期： <input style="width:80px">
            <a href="#" class="easyui-linkbutton" iconCls="icon-search">搜索</a>
        </div>
</div>
    
    <script type="text/javascript">
        var apiurl='?module=Api/FinanceTransactionLog';
        function saveItem(){
            $('#fm').form('submit',{
                url: apiurl+'&action=save',
                onSubmit: function(){
                    return $(this).form('validate');
                },
                success: function(result){
                    var result = eval('('+result+')');
                    if (result.errorMsg){
                        $.messager.show({
                            title: 'Error',
                            msg: result.errorMsg
                        });
                    } else {
                        $('#dlg').dialog('close');        // close the dialog
                        $('#dg').datagrid('reload');    // reload the user data
                    }
                }
            });
        }
        function destroyItem(){
            var row = $('#dg').datagrid('getSelected');
            if (row){
                $.messager.confirm('操作确认','您确定要删除此记录吗?',function(r){
                    if (r){
                        $.post(apiurl+'&action=remove',{id:row.ID},function(result){
                            if (result.success){
                                $('#dg').datagrid('reload');    // reload the user data
                            } else {
                                $.messager.show({    // show error message
                                    title: 'Error',
                                    msg: result.errorMsg
                                });
                            }
                        },'json');
                    }
                });
            }
        }
        /**
         * 获取状态的值
         * @param {type} id
         * @param {type} v
         * @returns {String}
         * @since 1.0 2014-3-22 by sutroon
         */
        function getStateStr(id,v){
            return v==1?'<a href="javascript:void(0)" onclick="setItemState('+id+',0);">正常</a>':'<a href="javascript:void(0)" onclick="setItemState('+id+',1);">关闭<a>'
        }
        /**
         * 更新记录的状态
         * @param {type} id
         * @param {type} v
         * @returns {undefined}
         * @since 1.0 2014-3-22 by sutroon
         */
        function setItemState(id,v){
            alert(id);
            $.post(apiurl+'&action=set_state',{id:id,state:v},function(result){
                            if (result.success){
                                $('#dg').datagrid('reload');    // reload the user data
                            } else {
                                $.messager.show({    // show error message
                                    title: 'Error',
                                    msg: result.errorMsg
                                });
                            }
                        },'json');
        }
         function setRowStyler(v){                
            switch(v){
                case '1':
                    return 'color:#090;';
                case '4':
                    return 'color:#F00;';
            }
	} 
        
    </script>